package infostroy.bookagolf.components.borders;

import infostroy.bookagolf.common.Constants.Colors;

import javax.swing.border.AbstractBorder;
import java.awt.*;

/**
 * Created by valer_000 on 2/9/14.
 */
public class RoundedBorder extends AbstractBorder implements Colors{

    @Override
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Graphics2D graphics = (Graphics2D) g;
        RenderingHints hints = graphics.getRenderingHints();

        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setColor(INPUT_BORDER);
        graphics.drawRoundRect(x, y, c.getWidth() - 1, c.getHeight() - 1, 10, 10);
        graphics.setRenderingHints(hints);
    }

    @Override
    public Insets getBorderInsets(Component c) {
        return new Insets(1, 1, 1, 1);
    }

    @Override
    public Insets getBorderInsets(Component c, Insets insets) {
        insets.left = insets.right = 2;
        insets.top = insets.bottom = 2;
        return insets;
    }
}
